#include <iostream>
#include<cstring>
#include<algorithm>
using namespace std;

class SeqList {
private:
	int* list;
	int maxsize, size;
public:
	SeqList();
	SeqList(int* data,int n);
	~SeqList();
	int list_size();		//实际长度
	int list_insert(int i,int item);	//插入
	int multi_insert(int i, int n, int item[]);		//连续插入
	int list_del(int i);		//删除
	int multi_del(int i, int n);	//从i开始连续删除n个数据
	int list_get(int i);		//获取
	void list_display();		//打印全表
	void LRmove(int op, int index,int &plist);		//循环移位，并打印表
};


SeqList::SeqList() {		//默认构造
	maxsize = 1000;
	size = 0;
	list = new int[maxsize];
}

SeqList::SeqList(int* data,int n) {
	maxsize = 1000;
	size = n;
	list = new int[maxsize];
	memcpy(list, data, sizeof(data)*n);
}

SeqList::~SeqList()
{
	delete[] list;
}

int SeqList::list_size() {
	return size;
}
int SeqList::list_insert(int i, int item) {
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//插入，后移
	size++;
	for (int j = size; j > i ; j--) {
		list[j] = list[j-1];
	}
	list[i] = item;
	return 0;
}
int SeqList::multi_insert(int i, int n, int item[]) {
	//连续插入
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//插入，后移
	size += n;
	for (int j = size; j > i; j--) {
		list[j] = list[j - n];
	}
	int tmp = 0;
	for (int j = i; j < i + n; j++) {
		list[j] = item[tmp];
		tmp++;
	}

	return 0;
}
int SeqList::list_del(int i) {
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//删除，前移
	for (int j = i; j < size; j++) {
		list[j] = list[j + 1];
	}
	size--;
	return 0;
}

int SeqList::multi_del(int i, int n) {
	//从i开始连续删除n个数据
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//删除，前移
	for (int j = i; j < i+n; j++) {
		list[j] = list[j + n];
	}
	size-=n;
	return 0;


}	
int SeqList::list_get(int i) {
	if (i < 1 || i >= size) {
		cout << "error\n";
		return -1;
	}
	return list[i];
}
void SeqList::list_display() {
	//cout << size << " ";
	for (int i = 0; i < size; i++) {
		cout << list[i]<<" ";
	}
	cout << endl;
}

void SeqList::LRmove(int op, int index, int& plist) {
	//实现循环移位的方法
	if (op == 0) {
		plist += index;
	}
	else {
		plist -= index;
	}


	plist %= size;		//使节点始终在[-size+1,size-1]内
	plist += size;
	plist %= size;		//强制模正,取值范围[0.size-1]

	//cout << "plist=" << plist << endl;	//调试信息
	int count = 0;
	for (int i = plist; count<size; i++) {
		if (i == size)i = 0;		//实现循环
		cout << list[i] << " ";
		count++;
	}
	cout << endl;
}


int main() {
	//此题依然偷鸡了一下，由于循环移位和“链表”很像，所以增加了一个节点指针，这样可以不破坏原来的顺序
	//同时增加了一个类方法“移位”方法，在方法内输出，不破坏类的封装性
	int n, index,temp;
	cin >> n;
	int* data = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> data[i];
	}
	SeqList list(data, n);
	list.list_display();

	//移位操作
	int op;
	int plist=0;	//节点指针，指循环移位的队首节点

	cin >>op>> index;
	list.LRmove(op, index,plist);

	cin >> op >> index;
	list.LRmove(op, index, plist);		
}